package com.zzyl.controller.customer;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.DeviceDto;
import com.zzyl.service.IotService;
import com.zzyl.vo.DeviceDataGraphVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/customer/user")
public class CustomerUserController {

    @Autowired
    private IotService iotService;

    /**
     * 查询物模型状态
     *
     * @param dto
     * @return
     */
    @PostMapping("/QueryDevicePropertyStatus")
    public ResponseResult queryDevicePropertyStatus(@RequestBody DeviceDto dto) {
        return ResponseResult.success(iotService.queryDevicePropertyStatus(dto));
    }

    /**
     * 根据小时查询 设备数据统计结果
     * @param iotId
     * @param functionId
     * @param startTime
     * @param endTime
     * @return
     */
    @GetMapping("/queryDeviceDataListByDay")
    public ResponseResult<List<DeviceDataGraphVo>> queryDeviceDataListByDay(
            @RequestParam String iotId,
            @RequestParam String functionId,
            @RequestParam Long startTime,
            @RequestParam Long endTime){

        List<DeviceDataGraphVo> list = iotService.queryDeviceDataListByDay(iotId, functionId, startTime, endTime);
        return ResponseResult.success(list);
    }

    /**
     * 按照周查询 设备数据统计结果
     * @param iotId
     * @param functionId
     * @param startTime
     * @param endTime
     * @return
     */
    @GetMapping("/queryDeviceDataListByWeek")
    public ResponseResult<List<DeviceDataGraphVo>> queryDeviceDataListByWeek(
            @RequestParam String iotId,
            @RequestParam String functionId,
            @RequestParam Long startTime,
            @RequestParam Long endTime){

        List<DeviceDataGraphVo> list = iotService.queryDeviceDataListByWeek(iotId, functionId, startTime, endTime);
        return ResponseResult.success(list);
    }

    @GetMapping("/pageQueryAlertData")
    public ResponseResult<List<DeviceDataGraphVo>> pageQueryAlertData(@RequestParam String iotId,
                                                                      @RequestParam String functionId,
                                                                      @RequestParam Long startTime,
                                                                      @RequestParam Long endTime){
        List<DeviceDataGraphVo> list = null;
        return ResponseResult.success(list);
    }
}
